import {Pipe, PipeTransform} from '@angular/core';
import {StringUtils} from '../utils/string-utils';

@Pipe({
    name: 'simpleEntityName'
})
export class SimpleEntityNamePipe implements PipeTransform {
    transform(value: string, strong = false): any {
        if (!value) {
            return value;
        }
        if (strong) {
            const index = value.lastIndexOf('.');
            if (index > -1) {
                return value.substring(index + 1);
            }
        }
        return StringUtils.toSimpleTypeName(value);
    }

}
